<template>
    <div class="index-lists">
        <el-card class="!border-none mt-4" shadow="never">
            <div>
                <el-button v-perms="['flow:add']" type="primary" @click="handleSubmit()">
                    <template #icon>
                        <icon name="el-icon-Plus" />
                    </template>
                    新增当前流程备注
                </el-button>
            </div>
            <el-table class="mt-4" size="large" v-loading="pager.loading" :data="pager.lists" stripe>
                <el-table-column type="selection" width="55" />
                <el-table-column label="流程阶段" prop="workflowStage" min-width="100" />
                <el-table-column label="办理人员" prop="acceptingOfficer" min-width="100" />
                <el-table-column label="办理时间" prop="handlingTime" min-width="100" />
                <el-table-column label="办理结果" prop="handlingResult" min-width="100" />
                <el-table-column label="办理意见" prop="handlingIdea" min-width="100" />
                <el-table-column label="备注" prop="remarks" min-width="100" />
            </el-table>
            <div class="flex justify-end mt-4">
                <pagination v-model="pager" @change="getLists" />
            </div>
            <el-dialog v-model="showEdit" title="当前流程备注" width="800">
                <el-input type="textarea" autocomplete="off" />
                <template #footer>
                    <div class="dialog-footer">
                        <el-button @click="showEdit = false">确认</el-button>
                        <el-button type="primary" @click="showEdit = false"> 取消 </el-button>
                    </div>
                </template>
            </el-dialog>
        </el-card>
      <footer-btns>
        <div style="padding: 20px">
          <el-button v-perms="['basic:add']" type="primary" @click="handleSubmit">
            <template #icon>
              <icon name="el-icon-Plus" />
            </template>
            新增
          </el-button>
          <el-button
              v-perms="['customerlist:add/edit']"
              type="primary"
              @click="save()"
          >
            <template #icon>
              <icon name="el-icon-FolderChecked" />
            </template>
            保存
          </el-button>
          <el-button @click="resetParams">重置</el-button>
        </div>
      </footer-btns>
    </div>
</template>
<script lang="ts" setup name="flow">
import { flowDelete, flowLists } from '@/api/flow'
import { usePaging } from '@/hooks/usePaging'
import feedback from '@/utils/feedback'
import type Popup from '@/components/popup/index.vue'

const queryParams = reactive({
    handlingIdea: '',
    remarks: ''
})

const { pager, getLists, resetPage, resetParams } = usePaging({
    fetchFun: flowLists,
    params: queryParams
})

const showEdit = ref(false)

const handleSubmit = async () => {
    showEdit.value = true
    await nextTick()
}

const handleDelete = async (id: number) => {
    await feedback.confirm('确定要删除？')
    await flowDelete({ id })
    feedback.msgSuccess('删除成功')
    getLists()
}

getLists()
</script>
